<?php
defined('BASEPATH') or exit('No direct script access allowed');
?>

<div class="row">
    <div class="col-sm-12">
        <div class="box">
            <div class="box-header with-border">
                <h2 class="page-header">
                    <i class="fa fa-globe"></i> 所有网站用户
                </h2>
            </div>
            <div class="box-body">

                <div class="mb-10">

                    <?php echo form_open(current_url(), array('class' => 'form-inline', 'method' => 'get', 'id' => 'search_goods')); ?>

                    <div class="form-group" style="margin-right:15px;">
                        <?php echo form_input($keyword); ?>
                    </div>
                    <?php echo form_button(array('type' => 'submit', 'class' => 'btn btn-sm btn-primary btn-flat', 'content' => "搜索用户")); ?>


                    <?php echo form_close(); ?>


                </div>

                <?php if ($loglist): ?>
                    <table class="table table-striped table-hover" style="margin-top:20px;">
                        <thead style="border-top:2px solid #eee;">
                        <tr>
                            <!-- <th>ID</th> -->
                            <th>网站</th>
                            <th>全名</th>
                            <th>Email</th>
                            <th>订单总数</th>
                            <th>订单总额</th>
                            <th>注册时间</th>
                            <th width="150"></th>
                        </tr>
                        </thead>
                        <tbody>
                        <?php foreach ($loglist as $item): ?>
                            <tr shopid="<?php echo $item["id"]; ?>">
                                <!-- <td><?php echo $item["id"]; ?></td> -->
                                <td><?php echo $sindex[$item["siteid"]]; ?></td>
                                <td><?php echo $item["realname"]; ?></td>
                                <td><?php echo $item["email"]; ?></td>
                                <td><?php echo $item["ordercount"]; ?></td>
                                <td>$ <?php echo $item["totalamount"]; ?></td>
                                <td><?php echo $item["regtime"]; ?></td>
                                <td>
                                    <?php echo anchor('backend/sites/order/index/' . $item["siteid"] . "?uid=" . $item["uid"], '<i class="fa fa-shopping-cart fa-lg"></i> 查看订单', 'class="btn btn-xs btn-success"'); ?>
                                </td>
                            </tr>

                        <?php endforeach; ?>
                        </tbody>
                    </table>
                <?php endif; ?>
                <?php
                if (empty($loglist)) {
                    echo "<h2 style='text-align:center;padding:50px 0;'>没有查询到数据</h2>";
                }
                ?>

                <?php echo $pager; ?>

                <div class=" pull-right form-inline" style="line-height:30px;margin-top:25px;">
                    <?php echo '共' . $total . '条产品，' . $page . '/' . $pages . '页'; ?>

                    <select id="pagesize" class="form-control input-sm" style="height:22px;">
                        <option value="0">每页数量</option>
                        <option value="50">50</option>
                        <option value="100">100</option>
                        <option value="200">200</option>
                        <option value="500">500</option>
                    </select>

                    <input type="text" id="topage" value="" class="form-control input-sm" placeholder='页码'
                           style="margin:0 5px;height:22px;width:45px;">
                    <?php echo form_button(array('type' => 'submit', 'class' => 'btn btn-xs btn-primary btn-flat', 'id' => 'jumpbtn', 'content' => "跳转")); ?>
                </div>

            </div>
        </div>
    </div>
</div>


<script>


    $("select#pagesize").change(function () {
        pagesize = $("select#pagesize option:selected").val();
        if (pagesize > 0) {
            var url = window.location.href;
            var newUrl = changeURLArg(url, "pagesize", pagesize);
            window.location.href = newUrl;
        }
    });


    function changeURLArg(url, arg, arg_val) {
        var pattern = arg + '=([^&]*)';
        var replaceText = arg + '=' + arg_val;
        if (url.match(pattern)) {
            var tmp = '/(' + arg + '=)([^&]*)/gi';
            tmp = url.replace(eval(tmp), replaceText);
            return tmp;
        } else {
            if (url.match('[\?]')) {
                return url + '&' + replaceText;
            } else {
                return url + '?' + replaceText;
            }
        }
        return url + '\n' + arg + '\n' + arg_val;
    }
</script>
